$(document).ready(function () {
    // var vConsole = new VConsole();
    var activityID = "40298198605804dc0160791fc3775299";
    var flag = false,
        submitfalg = true;
    var shareTxt = "一阳生，福利来！玩游戏赢免费旅游，温暖你整个冬季~";
    var shareLink = "http://tpn.gzl.com.cn/static/game/WinterSolstice/html/playgame.html";
    var ticketObj = untils.getQueryString("ticketObj");
    var checkToken = untils.getQueryString("checkToken");
    console.log('checkToken:', decodeURIComponent(checkToken));
    console.log('ticketObj:', ticketObj);



    //提交资料
    $('.submit_btn').click(function () {
        window.location = "http://weixin.gzl.cn/index.html";
    })

    //分享
    $('.share_lottery_btn').click(function () {
        $('.share_tip').show();
    })

    $('.share_tip .popup_bg').click(function () {
        $('.share_tip').hide();
    })

    // 更多惊喜
    $('.more_surpise').click(function () {
        window.location = "http://weixin.gzl.cn/index.html";
    })

    var bRotate = false;
    var rotateTimeOut = function () {
        $('#rotate').rotate({
            angle: 0,
            animateTo: 2160,
            duration: 8000,
            callback: function () {
                alert('网络超时，请检查您的网络设置！');
            }
        });
    };

    var rotateFn = function (awards, angles, txt) {
        bRotate = !bRotate;
        $('#rotate').stopRotate();
        $('#rotate').rotate({
            angle: 0,
            animateTo: angles + 1800,
            duration: 8000,
            callback: function () {
                $('.lottery_info').text(txt);
                if (txt == '旅行多用包') {
                    $('.situation_two').show().siblings('.situation_one').hide();
                    $('.lottery_box').hide('fast').siblings('.lottery_success').show();
                    $('.logo').show();
                } else if (txt == "谢谢参与") {
                    // $('.fail_share_tip').show();
                    $('.fail_box').show();
                } else {
                    $('.situation_one').show().siblings('.situation_two').hide()
                    $('.lottery_box').hide('fast').siblings('.lottery_success').show();
                    $('.logo').show();
                }
                
                bRotate = !bRotate;
            }
        })
    };


    // 一键分享
    $('.share_btn').click(function () {
        $('.fail_box').hide();
        $('.fail_share_tip').show();
    })
    $('.fail_share_tip .popup_bg').click(function () {
        $('.fail_share_tip').hide();
        $('.fail_box').show();
    })

    //开始抽奖
    $('.start_award').click(function () {
        if (bRotate) return;
        // untils.getluckyticket(activityID, "weixin", decodeURIComponent(checkToken), function (data) {
        //     console.log(data);
        //     switch (data.name) {
        //         case "清远熹乐谷温泉度假酒店":  //清远熹乐谷温泉度假酒店
        //             //var angle = [88, 137, 185, 235, 287];
        //             rotateFn(0, 0, data.name);
        //             break;
        //         case "谢谢参与":
        //             //var angle = [137, 185, 235, 287];
        //             rotateFn(1, 60, data.name);
        //             break;
        //         case "旅行多用包":
        //             //var angle = [137, 185, 235, 287];
        //             rotateFn(2, 120, data.name);
        //             break;
        //         case "谢谢参与":
        //             //var angle = [185, 235, 287];
        //             rotateFn(3, 180, data.name);
        //             break;
        //         case "长隆大马戏门票":  //上海迪士尼
        //             //var angle = [26, 88, 137, 185, 235, 287, 337];
        //             rotateFn(4, 240, data.name);
        //             break;
        //         case "谢谢参与":
        //             //var angle = [185, 235, 287];
        //             rotateFn(5, 300, data.name);
        //             break;
        //     }
        // })
    });



    /*GA点击统计*/
    var eventCategory = window.location.pathname.split('/')[3];
    $('.S_analyticsLabel').each(function () {
        $(this).click(function () {
            ga('send', 'event', eventCategory, 'click', $(this).attr('label'));
            ga('gz.send', 'event', eventCategory, 'click', $(this).attr('label'));
        });
    });

})